home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / dalla rivista / amiga.free / sorgenti vari / wolf3dmacsource.sit / Wolf3DMacSource / Wolf.68k < prev    next >
Text File  |  1994-09-30  |  5KB  |  164 lines

  1. ;
  2. ; Assembly language functions for wolf 3-D
  3. ; By Bill Heineman
  4. ; 9-12-94 (Rev to use tight loop for scale code)
  5. ;
  6. ; Call the compiled scaler
  7. ; void ScaleGlue(void *TextPtr,t_compscale *CodePtr);
  8. ;
  9.  
  10.     CASE    ON
  11.     
  12. WALLHEIGHT EQU 128+1
  13.  
  14.     EXPORT IO_ScaleWallColumn
  15.     EXPORT SpriteGlue
  16.     IMPORT VideoPointer:DATA
  17.     IMPORT VideoWidth:DATA
  18.     IMPORT ScaleDiv:DATA
  19.     IMPORT ArtData:DATA
  20.     IMPORT MacViewHeight:DATA
  21.  
  22. IO_ScaleWallColumn PROC
  23. Adder1    EQU    20
  24. ParmX        EQU    4+Adder1
  25. ParmScale    EQU    6+Adder1
  26. ParmTile    EQU    8+Adder1
  27. ParmColumn    EQU    10+Adder1
  28. ;
  29. ; D0 = Temp, A0 = Temp
  30. ;
  31.  
  32. RegScrn        EQU    A0        ;Pointer to the screen
  33. RegArt2        EQU    A1        ;True pointer to art
  34. RegArt        EQU    D1        ;Offset into the shape
  35. RegDelta    EQU    D2        ;Delta counter
  36. RegFrac        EQU    D3        ;Fixed point fraction
  37. RegInt        EQU    D4        ;Fixed point integer
  38. RegVidWidth EQU D5        ;Width of the screen in bytes
  39. RegScale    EQU    D6        ;Scale factor
  40.  
  41.     MOVEM.L    D2-D6,-(A7)        ;Save my registers
  42.     MOVE.L    #0,RegScale                ;Force scale to a long value
  43.     MOVE.W    ParmScale(A7),RegScale    ;Preload the scale factor
  44.     CMP.W    #0,RegScale            ;Scale of zero?
  45.     BEQ.S    ByeBye            ;Exit now! (Can't draw zero height)
  46.     
  47.     MOVE.W    ParmX(A7),D0    ;Get the X coord
  48.     MOVE.L    VideoPointer,RegScrn    ;Init the screen pointer
  49.     ADD.W    D0,RegScrn        ;Add the X coord
  50.     
  51.     MOVE.W    VideoWidth,RegVidWidth    ;Init the video width 
  52.     
  53.     LEA        ScaleDiv,RegArt2        ;Get pointer to the scaler recipocal table
  54.     MOVE.W    RegScale,D0        ;Place scale value in temp
  55.     LSL.W    #2,D0            ;Mul by 4 for longword index
  56.     MOVE.L    (RegArt2,D0.W),RegFrac    ;Get the precalced fraction
  57.     
  58.     ADD.W    RegScale,RegScale    ;Convert scale to pixel value
  59.     
  60.     MOVE.W    ParmColumn(A7),RegArt    ;Get the column index to the art
  61.     LSL.W    #7,RegArt                ;I have the pixel index
  62.     MOVE.W    ParmTile(A7),D0
  63.     LSL.W    #2,D0                    ;Shift down 7 up 2
  64.     LEA        ArtData,RegArt2            ;Get pointer to my shape ptr array
  65.     MOVE.L    (RegArt2,D0.W),RegArt2    ;Get the base pointer to the art in A2
  66.  
  67.     MOVE.W    MacViewHeight,D0        ;Get the height
  68.     CMP.W    D0,RegScale                ;Clipping needed?
  69.     BCC.S    ClipTop                    ;Do the clipped version
  70.     
  71.     SUB.W    RegScale,D0                ;How many line are clear?
  72.     LSR.W    #1,D0                    ;Number of lines to jump DOWN (Center it)
  73.     MULU.W    RegVidWidth,D0            ;Mul by bytes per line                    
  74.     ADD.L    D0,RegScrn                ;Add to the screen pointer
  75.  
  76.     MOVE.L    RegFrac,RegInt            ;Copy the full fixed point number
  77.     SWAP    RegInt                    ;Isolate the integer
  78.     MOVE.W    #0,RegDelta                ;Zap the delta
  79.     SUB.W    #1,RegScale                ;-1 from the count for DBF
  80. ;
  81. ; This is the tight loop that draws the scaled line
  82. ; RegArt2/RegArt = Source ptr
  83. ; RegScrn = Video pointer
  84. ; RegFrac = Scale fraction
  85. ; RegInt = Scale integer
  86. ; RegDelta = Scale delta
  87. ; RegScale = Pixel count (Max MacViewHeight)
  88. ;
  89.  
  90. Loopy
  91.     MOVE.B    (RegArt2,RegArt.W),D0    ;Move shape byte
  92.     MOVE.B    D0,(RegScrn)
  93.     ADD.W    RegFrac,RegDelta    ;Adjust the delta
  94.     ADDX.W    RegInt,RegArt        ;Adjust the source byte offset
  95.     ADD.W    RegVidWidth,RegScrn    ;Next dest scan line
  96.     DBF        RegScale,Loopy        ;Still more?
  97. ByeBye                        ;Exit
  98.     MOVEM.L    (A7)+,D2-D6
  99.     RTS
  100.     
  101. ClipTop
  102.     SUB.W    D0,RegScale                ;Number of lines clipped
  103.     LSR.W    #1,RegScale                ;True number of lines skipped from top
  104.     MOVE.W    RegFrac,RegDelta        ;Init the delta for the mul
  105.     MULU.W    RegScale,RegDelta        ;Make the new delta for skipped lines
  106.     MOVE.L    RegDelta,D0        ;Copy the delta
  107.     SWAP    D0                ;Isolate the integer
  108.     ADD.W    D0,RegArt        ;Skip the hidden lines
  109.     MOVE.L    RegFrac,D0
  110.     SWAP    D0
  111.     MULU.W    RegScale,D0
  112.     ADD.W    D0,RegArt
  113.     MOVE.L    RegFrac,RegInt            ;Copy the full fixed point number
  114.     SWAP    RegInt                    ;Isolate the integer
  115.     MOVE.W    MacViewHeight,RegScale    ;Use maximum height
  116.     SUB.W    #1,RegScale                ;Adjust for DBF
  117.     JMP        Loopy
  118.     
  119. ;
  120. ; Call the compiled scaler to draw a run of the line
  121. ;
  122. ;void SpriteGlue(Byte *a,LongWord b,Byte *c,Word d,Word e);
  123.  
  124. SpriteGlue PROC
  125. Off        EQU    20
  126. ParmSGArt    EQU    4+Off        ;Pointer to the 6 byte run structure
  127. ParmTFrac    EQU    8+Off        ;Pointer to the scaler
  128. ParmScrn    EQU    12+Off        ;Pointer to the run base address
  129. ParmCnt        EQU    16+Off        ;Line count    
  130. ParmDelta    EQU    18+Off        ;Initial delta
  131.  
  132.  
  133. SGArt2    EQU    A0        ;Pointer to the 6 byte run structure
  134. SGScrn    EQU    A1        ;Pointer to the run base address
  135. SGArt    EQU    D1
  136. SGFrac    EQU    D2        ;Pointer to the scaler
  137. SGInt    EQU D3        ;Pointer to the video
  138. SGCount    EQU D6
  139. SGDelta    EQU    D4
  140. SGVidWidth EQU D5
  141.  
  142.     MOVEM.L    D2-D6,-(A7)
  143.     MOVE.L    ParmSGArt(A7),SGArt2
  144.     MOVE.L    ParmScrn(A7),SGScrn
  145.     MOVE.L    ParmTFrac(A7),SGFrac    ;Get pointer to the run structure
  146.     MOVE.L    SGFrac,SGInt
  147.     SWAP    SGInt
  148.     MOVE.W    ParmCnt(A7),SGCount
  149.     MOVE.W    ParmDelta(A7),SGDelta
  150.     MOVE.W    VideoWidth,SGVidWidth    ;Init the video width 
  151.     MOVE.L    #0,SGArt
  152.     SUB.W    #1,SGCount        ;Adjust for count used in DBF
  153.     
  154. Loopy2
  155.     MOVE.B    (SGArt2,SGArt.W),D0    ;Get shape byte
  156.     MOVE.B    D0,(SGScrn)
  157.     ADD.W    SGFrac,SGDelta    ;Adjust the delta
  158.     ADDX.W    SGInt,SGArt        ;Adjust the source byte offset
  159.     ADD.W    SGVidWidth,SGScrn    ;Next dest scan line
  160.     DBF        SGCount,Loopy2        ;Still more?
  161.     MOVEM.L    (A7)+,D2-D6
  162.     RTS
  163.     END
  164.